import cv2


v_path = None
FPS = None
WIDTH, HEIGHT = None, None
cap = None
Total_Frame = None
Interval = None
IntervalFrame = None

def load_file() -> (bool,str):
    global v_path
    global FPS, WIDTH, HEIGHT,Total_Frame,Interval,IntervalFrame
    global cap
    try:
        if v_path is None:
            return (False,"file path is None")
        cap = cv2.VideoCapture(v_path)
        if not cap.isOpened():
            return (False,"video can't be opened")
        FPS = cap.get(cv2.CAP_PROP_FPS)
        WIDTH = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
        HEIGHT = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
        Total_Frame = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
        Interval = int(1000 / FPS)
        IntervalFrame = 0
        return (True,v_path)
    except Exception as ex:
        return (False,str(ex))



def analysis() -> (bool,str):


    return (True,v_path)

